<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>客户订单数据</title>
		  <#assign base=request.contextPath  />
		 <link rel="stylesheet" href="${base}/js/layui/css/layui.css?t=1534970980648" media="all">
		 <script type="text/javascript" src="${base}/js/zhang.js"></script>
		 <script src="${base}/js/layui/layui.js" charset="utf-8"></script>
         <script type="text/javascript" src="${base}/js/ztree/jquery-1.4.4.min.js"></script>
         <script src="${base}/js/jquery.min.js"></script>

		<style type="text/css">
		form{
		  padding:20px;
		}
		.layui-btn-radius{
        			border-radius: 5px;
        		}
		</style>
	</head>
	<body>
	<form class="layui-form" action="">
        <div class="layui-form-item">

                 <div class="layui-inline">
                          <label class="layui-form-label"><a style="color:red">*</a>&nbsp;房间号</label>
                                <div class="layui-input-block"style="width: 189px">
                                       <select name="city" lay-verify="required" lay-search="" class="isNull" id="home_id" >
                                        	<option value=""></option>

                                        </select>
                                   </div>
                               </div>

            <div class="layui-inline">
                 <label class="layui-form-label" style="width:120px"><a style="color:red">*</a>姓名</label>
                       <div class="layui-input-inline">
                            <input name="number" id="name" lay-verify="required" autocomplete="off" class="layui-input isNull" type="text">
                        </div>
                      </div>



                       <div class="layui-inline">
                                  <label class="layui-form-label"><a style="color:red">*</a>&nbsp;出生年月</label>
                                       <div class="layui-input-inline">
                                               <input name="date" id="date1" lay-verify="required|date" placeholder="yyyy-MM-dd" autocomplete="off" class="layui-input isNull" type="text">
                                         </div>
                                   </div>



                          <div class="layui-inline">
                                  <label class="layui-form-label" style="width:110px"><a style="color:red">*</a>大概预产期</label>
                                           <div class="layui-input-inline">
                                                      <input name="date" id="date2" lay-verify="required|date" placeholder="yyyy-MM-dd" autocomplete="off" class="layui-input isNull" type="text">
                                             </div>
                                  </div>




                        <div class="layui-inline">
                              <label class="layui-form-label" ><a style="color:red">*</a>&nbsp;家庭地址</label>
                                  <div class="layui-input-inline">
                                       <input name="number" id="address" lay-verify="required"  autocomplete="off" class="layui-input isNull" type="text">
                                  </div>
                        </div>





                         <div class="layui-inline">
                                       <label class="layui-form-label"style="width: 110px"><a style="color:red">*</a>&nbsp;成交日期</label>
                                           <div class="layui-input-inline">
                                                 <input name="date" id="date" lay-verify="required|date" placeholder="yyyy-MM-dd" autocomplete="off" class="layui-input isNull" type="text">
                                            </div>
                                      </div>

                        <div class="layui-inline">
                              <label class="layui-form-label" ><a style="color:red">*</a>&nbsp;联系电话</label>
                                  <div class="layui-input-inline">
                                       <input name="number" id="phone" lay-verify="required|phone|number"  autocomplete="off" class="layui-input isPhone" type="text">

                                  </div>
                        </div>


                        <div class="layui-inline">
                                    <label class="layui-form-label" style="width: 110px"><a style="color:red">*</a>&nbsp;微信</label>
                                           <div class="layui-input-inline">
                                                      <input name="number" id="weixin" lay-verify="required"  autocomplete="off" class="layui-input isNull" type="text">
                                           </div>
                                </div>


                         <div class="layui-inline">
                                <label class="layui-form-label" ><a style="color:red">*</a>&nbsp;沟通时长</label>
                                         <div class="layui-input-inline">
                                                    <input name="number" id="howLong" lay-verify="required"  autocomplete="off" class="layui-input isNull" type="text">
                                             </div>
                                      </div>
                      <!--<div class="layui-inline">
                            <label class="layui-form-label" ><a style="color:red">*</a>&nbsp;客户来源</label>
                                        <div class="layui-input-inline">
                                              <input name="number" id="customerSource" lay-verify="required"  autocomplete="off" class="layui-input isNull" type="text">
                                      </div>
                            </div>-->





                       <div class="layui-inline">
                           <label class="layui-form-label" style="width: 110px"><a style="color:red">*</a>&nbsp;是否接送</label>
                                      <div class="layui-input-inline">
                                       <input name="number" id="Relay" lay-verify="required"  autocomplete="off" class="layui-input isNull" type="text">
                                    </div>
                           </div>
            <div class="layui-inline">
                <label class="layui-form-label"><a style="color:red">*</a>客户来源</label>
                <div class="layui-input-block"   style="width:189px">
                    <select  lay-verify="required" lay-search="" class="isNull" id="customerSource">
                        <option value="">请选择客户渠道</option>
                        <option value="360">360</option>
                        <option value="百度">百度</option>
                        <option value="大众点评">大众点评</option>
                        <option value="上门参观">上门参观</option>
                        <option value="异业联盟">异业联盟</option>
                        <option value="400主动咨询">400主动咨询</option>
                        <option value="老客户转介绍">老客户转介绍</option>
                    </select>
                </div>
            </div>


                            <div class="layui-inline">
                           <label class="layui-form-label"  style="width:120px"><a style="color:red">*</a>&nbsp;有无产前陪同</label>
                                    <div class="layui-input-inline">
                                       <input name="number" id="PrenatalEscort" lay-verify="required"  autocomplete="off" class="layui-input isNull" type="text">
                                    </div>
                           </div>


                    <div class="layui-inline">
                          <label class="layui-form-label"><a style="color:red">*</a>&nbsp;套餐项</label>
                                <div class="layui-input-block"style="width: 189px">
                                       <select name="city" lay-verify="required" class=" isNull" id="setMeal">
                                        	<option value=""></option>

                                        </select>
                                   </div>
                               </div>


                                    <div class="layui-inline">
                           <label class="layui-form-label" style="width:120px"><a style="color:red">*</a>&nbsp;病历史</label>
                                      <div class="layui-input-inline">
                                       <input name="number" id="disease" lay-verify="required"  autocomplete="off" class="layui-input isNull" type="text">
                                    </div>
                           </div>
                           <div class="layui-inline">
                                                               <label class="layui-form-label" ><a style="color:red">*</a>&nbsp;定金</label>
                                                                        <div class="layui-input-inline">
                                                                             <input name="number" id="setMoney" lay-verify="required|number"  autocomplete="off" class="layui-input isNull" type="text">
                                                                             </div>
                                                                      </div>
                        <div class="layui-inline">
                                  <label class="layui-form-label"style="width:110px" ><a style="color:red">*</a>&nbsp;计划生产医院</label>
                                           <div class="layui-input-inline">
                                                <input name="number" id="hospital" lay-verify="required"  autocomplete="off" class="layui-input isNull" type="text">
                                          </div>
                                  </div>
                      <!--  <div class="layui-inline">
                                <label class="layui-form-label" ><a style="color:red">*</a>&nbsp;押金</label>
                                         <div class="layui-input-inline">
                                                <input name="number" id="deposit" lay-verify="required|number"  autocomplete="off" class="layui-input isNull" type="text">
                                           </div>
                                    </div>-->

                                            <div class="layui-inline">
                                                                        <label class="layui-form-label" ><a style="color:red">*</a>&nbsp;录入人</label>
                                                                                 <div class="layui-input-inline">
                                                                                          <input name="number" id="person" lay-verify="required"  autocomplete="off" class="layui-input isNull" type="text">
                                                                               </div>
                                                                             </div>
                           <div class="layui-inline">
                                        <label class="layui-form-label" style="width:110px"><a style="color:red">*</a>&nbsp;有无特殊需求</label>
                                                  <div class="layui-input-inline">
                                                           <input name="number" id="specialRequirements" lay-verify="required"  autocomplete="off" class="layui-input isNull" type="text">
                                                </div>
                                         </div>

               <div class="layui-form-item" style="text-align:center;">
                       <div class="layui-input-block">
                           <button class="layui-btn layui-btn-radius" lay-submit lay-filter="formDemo" type="button" onclick="onSubmit()" style="background-color: #0092EF;">立即提交</button>
                           <button type="reset" class="layui-btn layui-btn-primary layui-btn-radius">重置</button>
                     </div>
               </div>
            </div>
        </form>

<script>
layui.use(['form', 'layedit', 'laydate','layer'], function(){
  var form = layui.form
  ,layer = layui.layer
  ,layedit = layui.layedit
  ,laydate = layui.laydate;
   //日期
  laydate.render({
    elem: '#date'
  });
   laydate.render({
      elem: '#date1'
    });
     laydate.render({
        elem: '#date2'
      });




});
var subFlag=true;

//添加
function onSubmit(){
//alert($('input:radio[name="sex"]:checked').val())
var jsonData = {};
     //房间名字
     jsonData.homeId = $("#home_id").val();
    //姓名
    jsonData.name = $("#name").val();

    //出生日期
    jsonData.birth = $("#date1").val();
    //大概预产期
    jsonData.childbirth = $("#date2").val();
    //家庭住址
    jsonData.address = $("#address").val();
    //成交日期
    jsonData.dateOfTransaction = $("#date").val();
    //电话
    jsonData.phone = $("#phone").val();
    //微信
    jsonData.weixin = $("#weixin").val();
    //沟通时长
    jsonData.howLong = $("#howLong").val();
    //客户来源渠道
    jsonData.customerSource = $("#customerSource").val();
    //是否接送
    jsonData.Relay = $("#Relay").val();
    //有没有产前陪同
    jsonData.PrenatalEscort = $("#PrenatalEscort").val();
    //套餐项
    jsonData.setMeal = $("#setMeal").val();
    //病历史
    jsonData.disease = $("#disease").val();
    //计划生产医院
    jsonData.hospital = $("#hospital").val();
    //押金
   // jsonData.deposit = $("#deposit").val();
    //定金
    jsonData.setMoney = $("#setMoney").val();
    //录入人
    jsonData.person = $("#person").val();
    //有无特殊需求
    jsonData.specialRequirements = $("#specialRequirements").val();
     //验证手机号
     if(!isPhone()){
        return;
      }
    //验证非空
    if(!isNull()){
        return;
       }


        //alert("进入ajax")
        if(subFlag){
        subFlag=false;

           $.ajax({
                type:"POST",
                url:"${base}/trVip/insertTrVip",
                data:{"param":JSON.stringify(jsonData)},
                success:function(data){
        subFlag=true;
                     layer.msg(data);
        setTimeout(function(){
           var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                  parent.layer.close(index); //再执行关闭
        },500)
                     //清空表格
                         //房间名字
                              jsonData.homeId = $("#home_id").val("");
                             //姓名
                             jsonData.name = $("#name").val("");
                             //性别

                             //出生日期
                             jsonData.birth = $("#birth").val("");
                             //大概预产期
                             jsonData.childbirth = $("#childbirth").val("");
                             //家庭住址
                             jsonData.address = $("#address").val("");
                             //成交日期
                             jsonData.dateOfTransaction = $("#date").val("");
                             //电话
                             jsonData.phone = $("#phone").val("");
                             //微信
                             jsonData.weixin = $("#weixin").val("");
                             //沟通时长
                             jsonData.howLong = $("#howLong").val("");
                             //客户来源渠道
                             jsonData.customerSource = $("#customerSource").val("");
                             //是否接送
                             jsonData.Relay = $("#Relay").val("");
                             //有没有产前陪同
                             jsonData.PrenatalEscort = $("#PrenatalEscort").val("");
                             //套餐项
                             jsonData.setMeal = $("#setMeal").val("");
                             //病历史
                             jsonData.disease = $("#disease").val("");
                             //计划生产医院
                             jsonData.hospital = $("#hospital").val("");
                             //押金
                             //jsonData.deposit = $("#deposit").val("");
                             //定金
                             jsonData.setMoney = $("#setMoney").val("");
                             //录入人
                             jsonData.person = $("#person").val("");
                             //有无特殊需求
                             jsonData.specialRequirements = $("#specialRequirements").val("");
                     var table = parent.layui.table;
                        //表刷新方法
                        table.reload('testReload', {
                        url: '${base}/trVip/selectTrVip'
                        ,where: {} //设定异步数据接口的额外参数
                        //,height: 300
                    });
                }
             });
        }else{
          layer.msg("正在保存...请稍后");
        }


}

//获取添加时候的房间id
var bas = "${base}"
//home:变量  = zhang.js里边封装的名称(路径,"字典表里边的code")
var home_data = getDataByDicCode(bas,"home")
for(var i=0;i<home_data.length;i++){
$("#home_id").append(
    ' <option value="'+home_data[i].id+'">'+home_data[i].name+'</option>'
)
}

//获取添加时候的套餐项
var bas = "${base}"
var home_meal = getMealName(bas,"mealName")
for(var i=0;i<home_meal.length;i++){
$("#setMeal").append(
    ' <option value="'+home_meal[i].id+'">'+home_meal[i].mealName+'</option>'
)
}


</script>
	</body>
</html>
